import request from '@/utils/request'

export default {
  login(data){
    return request({
      url: '/auth/login',
      method: 'post',
      data
    })
  },
  getInfo(token){
    return request({
      url: '/auth/me',
      method: 'get',
      params: { token }
    })
  },
  refreshToken(){
    return request({
      url:'/auth/refresh',
      method:'get'
    })
  },
  logout(){
    return request({
      url: '/auth/logout',
      method: 'get'
    })
  },
  updatePwd(data){
    return request({
      url:'/users/chgpwd',
      method:'post',
      data
    })
  },
  queryUser(tableQuery, tablePage){
    let params={
      page:tablePage.current?tablePage.current:1,
      num:tablePage.size?tablePage.size:20,
      search:tableQuery.name,
      roleid:tableQuery.roleid
    }
    return request({
      url:'/users',
      method:'get',
      params
    })
  },
  orgnizeUsers(oid){
    return request({
      url:'/users/lists',
      method:'get',
      params:{orgnization_id:oid}
    })
  },
  storeUser(data){
    return request({
      url:'/users/store',
      method:'post',
      data
    })
  },
  deleteUser(data){
    return request({
      url:'/users/delete',
      method:'post',
      data
    })
  },
  resetPwd(data){
    return request({
      url:'/users/resetpwd',
      method:'post',
      data
    })
  },
  userRole(uid){
    return request({
      url:`/users/${uid}/role`,
      method:'get'
    })
  },
  storeUserRole(data){
    return request({
      url:`/users/${data.id}/role`,
      method:'post',
      data
    })
  },
  userOrgnizes(uid){
    return request({
      url:`/users/${uid}/orgnization`,
      method:'get'
    })
  },
  storeUserOrgnize(uid, orgnizations){
    return request({
      url:`/users/${uid}/orgnization`,
      method:'post',
      data:{orgnizations}
    })
  },
  systemSwitch(data){
    return request({
      url:'/auth/switch',
      method:'post',
      data
    })
  }


}
